import unittest

from aggmon.importers.nagios_status_log import NagiosStatusLogImporter
from basic_types.metric import Metric


NAGIOS_STATUS_LOG = """\
########################################
#          NAGIOS STATUS FILE
#
# THIS FILE IS AUTOMATICALLY GENERATED
# BY NAGIOS.  DO NOT MODIFY THIS FILE!
########################################

info {
    created=1246372714
    version=2.9
    }

program {
    modified_host_attributes=0
    modified_service_attributes=0
    nagios_pid=6597
    daemon_mode=1
    program_start=1246358090
    last_command_check=1246372699
    last_log_rotation=0
    enable_notifications=1
    active_service_checks_enabled=1
    passive_service_checks_enabled=1
    active_host_checks_enabled=1
    passive_host_checks_enabled=1
    enable_event_handlers=1
    obsess_over_services=0
    obsess_over_hosts=0
    check_service_freshness=1
    check_host_freshness=0
    enable_flap_detection=0
    enable_failure_prediction=1
    process_performance_data=0
    global_host_event_handler=
    global_service_event_handler=
    total_external_command_buffer_slots=4096
    used_external_command_buffer_slots=0
    high_external_command_buffer_slots=0
    total_check_result_buffer_slots=4096
    used_check_result_buffer_slots=1
    high_check_result_buffer_slots=5
    }

host {
    host_name=dmds
    modified_attributes=0
    check_command=check-host-alive
    event_handler=
    has_been_checked=1
    should_be_scheduled=0
    check_execution_time=0.005
    check_latency=0.000
    check_type=0
    current_state=0
    last_hard_state=1
    plugin_output=PING OK - Packet loss = 0%, RTA = 0.04 ms
    performance_data=
    last_check=1218741066
    next_check=0
    current_attempt=0
    max_attempts=10
    state_type=1
    last_state_change=1218741066
    last_hard_state_change=1218741066
    last_time_up=1218798728
    last_time_down=1218798258
    last_time_unreachable=0
    last_notification=1218741066
    next_notification=0
    no_more_notifications=0
    current_notification_number=0
    notifications_enabled=1
    problem_has_been_acknowledged=0
    acknowledgement_type=0
    active_checks_enabled=1
    passive_checks_enabled=1
    event_handler_enabled=1
    flap_detection_enabled=1
    failure_prediction_enabled=1
    process_performance_data=1
    obsess_over_host=1
    last_update=1246372714
    is_flapping=0
    percent_state_change=0.00
    scheduled_downtime_depth=0
    }

host {
    host_name=dmds1
    modified_attributes=1
    check_command=check-host-alive
    event_handler=
    has_been_checked=1
    should_be_scheduled=0
    check_execution_time=0.006
    check_latency=0.000
    check_type=0
    current_state=0
    last_hard_state=0
    plugin_output=PING OK - Packet loss = 0%, RTA = 0.11 ms
    performance_data=
    last_check=1246372544
    next_check=0
    current_attempt=1
    max_attempts=10
    state_type=1
    last_state_change=1246358944
    last_hard_state_change=1246358291
    last_time_up=1246372544
    last_time_down=1246358944
    last_time_unreachable=0
    last_notification=0
    next_notification=0
    no_more_notifications=0
    current_notification_number=0
    notifications_enabled=1
    problem_has_been_acknowledged=0
    acknowledgement_type=0
    active_checks_enabled=1
    passive_checks_enabled=1
    event_handler_enabled=1
    flap_detection_enabled=1
    failure_prediction_enabled=1
    process_performance_data=1
    obsess_over_host=1
    last_update=1246372714
    is_flapping=0
    percent_state_change=6.25
    scheduled_downtime_depth=0
    }

host {
    host_name=dmds2
    modified_attributes=0
    check_command=check-host-alive
    event_handler=
    has_been_checked=1
    should_be_scheduled=0
    check_execution_time=0.006
    check_latency=0.000
    check_type=0
    current_state=0
    last_hard_state=0
    plugin_output=PING OK - Packet loss = 0%, RTA = 0.03 ms
    performance_data=
    last_check=1246372614
    next_check=0
    current_attempt=1
    max_attempts=10
    state_type=1
    last_state_change=1216752569
    last_hard_state_change=1216752569
    last_time_up=1246372614
    last_time_down=1216809255
    last_time_unreachable=0
    last_notification=0
    next_notification=0
    no_more_notifications=0
    current_notification_number=0
    notifications_enabled=1
    problem_has_been_acknowledged=0
    acknowledgement_type=0
    active_checks_enabled=1
    passive_checks_enabled=1
    event_handler_enabled=1
    flap_detection_enabled=1
    failure_prediction_enabled=1
    process_performance_data=1
    obsess_over_host=1
    last_update=1246372714
    is_flapping=0
    percent_state_change=0.00
    scheduled_downtime_depth=0
    }

host {
    host_name=doss1
    modified_attributes=0
    check_command=check-host-alive
    event_handler=
    has_been_checked=1
    should_be_scheduled=0
    check_execution_time=0.006
    check_latency=0.000
    check_type=0
    current_state=0
    last_hard_state=0
    plugin_output=PING OK - Packet loss = 0%, RTA = 0.10 ms
    performance_data=
    last_check=1246372594
    next_check=0
    current_attempt=1
    max_attempts=10
    state_type=1
    last_state_change=1246357058
    last_hard_state_change=1246357058
    last_time_up=1246372594
    last_time_down=1246356916
    last_time_unreachable=0
    last_notification=1246357058
    next_notification=0
    no_more_notifications=0
    current_notification_number=0
    notifications_enabled=1
    problem_has_been_acknowledged=0
    acknowledgement_type=0
    active_checks_enabled=1
    passive_checks_enabled=1
    event_handler_enabled=1
    flap_detection_enabled=1
    failure_prediction_enabled=1
    process_performance_data=1
    obsess_over_host=1
    last_update=1246372714
    is_flapping=0
    percent_state_change=0.00
    scheduled_downtime_depth=0
    }

host {
    host_name=doss2
    modified_attributes=0
    check_command=check-host-alive
    event_handler=
    has_been_checked=1
    should_be_scheduled=0
    check_execution_time=0.006
    check_latency=0.000
    check_type=0
    current_state=0
    last_hard_state=0
    plugin_output=PING OK - Packet loss = 0%, RTA = 0.09 ms
    performance_data=
    last_check=1246372664
    next_check=0
    current_attempt=1
    max_attempts=10
    state_type=1
    last_state_change=1246366364
    last_hard_state_change=1246366364
    last_time_up=1246372664
    last_time_down=1246366204
    last_time_unreachable=0
    last_notification=1246366364
    next_notification=1246395164
    no_more_notifications=0
    current_notification_number=0
    notifications_enabled=1
    problem_has_been_acknowledged=0
    acknowledgement_type=0
    active_checks_enabled=1
    passive_checks_enabled=1
    event_handler_enabled=1
    flap_detection_enabled=1
    failure_prediction_enabled=1
    process_performance_data=1
    obsess_over_host=1
    last_update=1246372714
    is_flapping=0
    percent_state_change=6.25
    scheduled_downtime_depth=0
    }

host {
    host_name=osb1raid1
    modified_attributes=0
    check_command=check-host-alive
    event_handler=
    has_been_checked=1
    should_be_scheduled=0
    check_execution_time=0.007
    check_latency=0.000
    check_type=0
    current_state=0
    last_hard_state=0
    plugin_output=PING OK - Packet loss = 0%, RTA = 0.20 ms
    performance_data=
    last_check=1244076247
    next_check=0
    current_attempt=1
    max_attempts=10
    state_type=1
    last_state_change=1233223088
    last_hard_state_change=1233223088
    last_time_up=1244076247
    last_time_down=1233229973
    last_time_unreachable=0
    last_notification=1233223088
    next_notification=0
    no_more_notifications=0
    current_notification_number=0
    notifications_enabled=1
    problem_has_been_acknowledged=0
    acknowledgement_type=0
    active_checks_enabled=1
    passive_checks_enabled=1
    event_handler_enabled=1
    flap_detection_enabled=1
    failure_prediction_enabled=1
    process_performance_data=1
    obsess_over_host=1
    last_update=1246372714
    is_flapping=0
    percent_state_change=0.00
    scheduled_downtime_depth=0
    }

service {
    host_name=dmds
    service_description=gmetad
    modified_attributes=0
    check_command=check_service_up!gmetad
    event_handler=handle_restart
    has_been_checked=1
    should_be_scheduled=1
    check_execution_time=0.103
    check_latency=0.916
    check_type=0
    current_state=0
    last_hard_state=0
    current_attempt=1
    max_attempts=4
    state_type=1
    last_state_change=1218741060
    last_hard_state_change=1218740491
    last_time_ok=1246372655
    last_time_warning=0
    last_time_unknown=1218798153
    last_time_critical=0
    plugin_output=Service gmetad is running.
    performance_data=
    last_check=1246372655
    next_check=1246372955
    current_notification_number=0
    last_notification=0
    next_notification=0
    no_more_notifications=0
    notifications_enabled=1
    active_checks_enabled=1
    passive_checks_enabled=1
    event_handler_enabled=1
    problem_has_been_acknowledged=0
    acknowledgement_type=0
    flap_detection_enabled=1
    failure_prediction_enabled=1
    process_performance_data=1
    obsess_over_service=1
    last_update=1246372714
    is_flapping=0
    percent_state_change=0.00
    scheduled_downtime_depth=0
    }

service {
    host_name=dmds
    service_description=nfs
    modified_attributes=0
    check_command=check_service_up!nfs
    event_handler=handle_restart
    has_been_checked=1
    should_be_scheduled=1
    check_execution_time=0.148
    check_latency=0.697
    check_type=0
    current_state=0
    last_hard_state=0
    current_attempt=1
    max_attempts=4
    state_type=1
    last_state_change=1216752539
    last_hard_state_change=1216751574
    last_time_ok=1246372520
    last_time_warning=0
    last_time_unknown=1216809536
    last_time_critical=0
    plugin_output=Service nfs is running.
    performance_data=
    last_check=1246372520
    next_check=1246372820
    current_notification_number=0
    last_notification=0
    next_notification=0
    no_more_notifications=0
    notifications_enabled=1
    active_checks_enabled=1
    passive_checks_enabled=1
    event_handler_enabled=1
    problem_has_been_acknowledged=0
    acknowledgement_type=0
    flap_detection_enabled=1
    failure_prediction_enabled=1
    process_performance_data=1
    obsess_over_service=1
    last_update=1246372714
    is_flapping=0
    percent_state_change=0.00
    scheduled_downtime_depth=0
    }

service {
    host_name=dmds1
    service_description=HA state
    modified_attributes=0
    check_command=check_crm_ssh
    event_handler=
    has_been_checked=1
    should_be_scheduled=1
    check_execution_time=0.340
    check_latency=0.670
    check_type=0
    current_state=1
    last_hard_state=1
    current_attempt=3
    max_attempts=3
    state_type=1
    last_state_change=1246358585
    last_hard_state_change=1246358705
    last_time_ok=1232369819
    last_time_warning=1246372505
    last_time_unknown=1246357086
    last_time_critical=1239011847
    plugin_output=WARNING - DC choosen: 1/2 nodes online: 11/13 resources online: Resources NOT balanced! 0 failed actions:
    performance_data=
    last_check=1246372505
    next_check=1246372805
    current_notification_number=302
    last_notification=1246358711
    next_notification=1246394711
    no_more_notifications=0
    notifications_enabled=1
    active_checks_enabled=1
    passive_checks_enabled=1
    event_handler_enabled=1
    problem_has_been_acknowledged=0
    acknowledgement_type=0
    flap_detection_enabled=1
    failure_prediction_enabled=1
    process_performance_data=1
    obsess_over_service=1
    last_update=1246372714
    is_flapping=0
    percent_state_change=0.00
    scheduled_downtime_depth=0
    }

service {
    host_name=dmds1
    service_description=Heartbeat link state
    modified_attributes=0
    check_command=check_heartbeat_link_ssh
    event_handler=
    has_been_checked=1
    should_be_scheduled=1
    check_execution_time=0.286
    check_latency=0.743
    check_type=0
    current_state=0
    last_hard_state=0
    current_attempt=1
    max_attempts=3
    state_type=1
    last_state_change=1246358750
    last_hard_state_change=1246356979
    last_time_ok=1246372550
    last_time_warning=0
    last_time_unknown=1246356979
    last_time_critical=1216817780
    plugin_output=Heartbeat Link OK: ib0group:ib0group:up eth0group:eth0group:up dmds2.localdomain:eth1:up dmds2.localdomain:eth0:up
    performance_data=
    last_check=1246372550
    next_check=1246372850
    current_notification_number=0
    last_notification=0
    next_notification=0
    no_more_notifications=0
    notifications_enabled=1
    active_checks_enabled=1
    passive_checks_enabled=1
    event_handler_enabled=1
    problem_has_been_acknowledged=0
    acknowledgement_type=0
    flap_detection_enabled=1
    failure_prediction_enabled=1
    process_performance_data=1
    obsess_over_service=1
    last_update=1246372714
    is_flapping=0
    percent_state_change=0.00
    scheduled_downtime_depth=0
    }

service {
    host_name=dmds1
    service_description=IB state
    modified_attributes=0
    check_command=check_iberr_ssh
    event_handler=
    has_been_checked=1
    should_be_scheduled=1
    check_execution_time=0.337
    check_latency=0.717
    check_type=0
    current_state=3
    last_hard_state=3
    current_attempt=3
    max_attempts=3
    state_type=1
    last_state_change=1245405910
    last_hard_state_change=1245406030
    last_time_ok=1245078039
    last_time_warning=1215186096
    last_time_unknown=1246372535
    last_time_critical=1232369851
    plugin_output=Script could not be executed without errors: Possibly
    performance_data=
    last_check=1246372535
    next_check=1246372835
    current_notification_number=0
    last_notification=0
    next_notification=0
    no_more_notifications=0
    notifications_enabled=1
    active_checks_enabled=1
    passive_checks_enabled=1
    event_handler_enabled=1
    problem_has_been_acknowledged=0
    acknowledgement_type=0
    flap_detection_enabled=1
    failure_prediction_enabled=1
    process_performance_data=1
    obsess_over_service=1
    last_update=1246372714
    is_flapping=0
    percent_state_change=0.00
    scheduled_downtime_depth=0
    }

service {
    host_name=dmds1
    service_description=Lustre LBUG
    modified_attributes=0
    check_command=check_gangmet!lbug!1!1!LustreSrv!
    event_handler=
    has_been_checked=1
    should_be_scheduled=1
    check_execution_time=0.009
    check_latency=0.794
    check_type=0
    current_state=0
    last_hard_state=0
    current_attempt=1
    max_attempts=4
    state_type=1
    last_state_change=1243944996
    last_hard_state_change=1243944996
    last_time_ok=1246366280
    last_time_warning=1212400696
    last_time_unknown=1243937796
    last_time_critical=1213367734
    plugin_output=lbug = 0, normal
    performance_data=
    last_check=1246366280
    next_check=1246373480
    current_notification_number=0
    last_notification=0
    next_notification=0
    no_more_notifications=0
    notifications_enabled=1
    active_checks_enabled=1
    passive_checks_enabled=1
    event_handler_enabled=1
    problem_has_been_acknowledged=0
    acknowledgement_type=0
    flap_detection_enabled=1
    failure_prediction_enabled=1
    process_performance_data=1
    obsess_over_service=1
    last_update=1246372714
    is_flapping=0
    percent_state_change=0.00
    scheduled_downtime_depth=0
    }

service {
    host_name=dmds1
    service_description=OSTs deactivated
    modified_attributes=0
    check_command=check_deactivated
    event_handler=
    has_been_checked=1
    should_be_scheduled=1
    check_execution_time=0.215
    check_latency=0.961
    check_type=0
    current_state=0
    last_hard_state=0
    current_attempt=1
    max_attempts=3
    state_type=1
    last_state_change=1246358283
    last_hard_state_change=1246357084
    last_time_ok=1246372683
    last_time_warning=1216399793
    last_time_unknown=1246357084
    last_time_critical=1242030933
    plugin_output=OK: not on MGS node
    performance_data=
    last_check=1246372683
    next_check=1246373583
    current_notification_number=0
    last_notification=0
    next_notification=0
    no_more_notifications=0
    notifications_enabled=1
    active_checks_enabled=1
    passive_checks_enabled=1
    event_handler_enabled=1
    problem_has_been_acknowledged=0
    acknowledgement_type=0
    flap_detection_enabled=1
    failure_prediction_enabled=1
    process_performance_data=1
    obsess_over_service=1
    last_update=1246372714
    is_flapping=0
    percent_state_change=8.16
    scheduled_downtime_depth=0
    }

service {
    host_name=dmds1
    service_description=Udev path check
    modified_attributes=0
    check_command=check_udev_ssh!mds!
    event_handler=
    has_been_checked=1
    should_be_scheduled=1
    check_execution_time=0.684
    check_latency=0.564
    check_type=0
    current_state=0
    last_hard_state=0
    current_attempt=1
    max_attempts=3
    state_type=1
    last_state_change=1246359004
    last_hard_state_change=1243938124
    last_time_ok=1246372444
    last_time_warning=0
    last_time_unknown=1246358944
    last_time_critical=1225814437
    plugin_output=18286: old priority 0, new priority -10
    performance_data=
    last_check=1246372444
    next_check=1246372924
    current_notification_number=0
    last_notification=0
    next_notification=0
    no_more_notifications=0
    notifications_enabled=1
    active_checks_enabled=1
    passive_checks_enabled=1
    event_handler_enabled=1
    problem_has_been_acknowledged=0
    acknowledgement_type=0
    flap_detection_enabled=1
    failure_prediction_enabled=1
    process_performance_data=1
    obsess_over_service=1
    last_update=1246372714
    is_flapping=0
    percent_state_change=0.00
    scheduled_downtime_depth=0
    }

service {
    host_name=dmds1
    service_description=software raids
    modified_attributes=0
    check_command=check_raids_ssh
    event_handler=
    has_been_checked=1
    should_be_scheduled=1
    check_execution_time=0.478
    check_latency=0.058
    check_type=0
    current_state=0
    last_hard_state=0
    current_attempt=1
    max_attempts=3
    state_type=1
    last_state_change=1245071737
    last_hard_state_change=1243938229
    last_time_ok=1246372113
    last_time_warning=0
    last_time_unknown=1243937329
    last_time_critical=1245071437
    plugin_output=All (4) RAIDs ok.
    performance_data=
    last_check=1246372113
    next_check=1246373013
    current_notification_number=0
    last_notification=0
    next_notification=0
    no_more_notifications=0
    notifications_enabled=1
    active_checks_enabled=1
    passive_checks_enabled=1
    event_handler_enabled=1
    problem_has_been_acknowledged=0
    acknowledgement_type=0
    flap_detection_enabled=1
    failure_prediction_enabled=1
    process_performance_data=1
    obsess_over_service=1
    last_update=1246372714
    is_flapping=0
    percent_state_change=0.00
    scheduled_downtime_depth=0
    }

service {
    host_name=dmds2
    service_description=HA state
    modified_attributes=0
    check_command=check_crm_ssh
    event_handler=
    has_been_checked=1
    should_be_scheduled=1
    check_execution_time=0.347
    check_latency=0.787
    check_type=0
    current_state=1
    last_hard_state=1
    current_attempt=3
    max_attempts=3
    state_type=1
    last_state_change=1233304898
    last_hard_state_change=1233305018
    last_time_ok=1233311825
    last_time_warning=1246372578
    last_time_unknown=1216810217
    last_time_critical=0
    plugin_output=WARNING - DC choosen: 1/2 nodes online: 11/13 resources online: 0 failed actions:
    performance_data=
    last_check=1246372578
    next_check=1246372878
    current_notification_number=272
    last_notification=1246343189
    next_notification=1246379189
    no_more_notifications=0
    notifications_enabled=1
    active_checks_enabled=1
    passive_checks_enabled=1
    event_handler_enabled=1
    problem_has_been_acknowledged=0
    acknowledgement_type=0
    flap_detection_enabled=1
    failure_prediction_enabled=1
    process_performance_data=1
    obsess_over_service=1
    last_update=1246372714
    is_flapping=0
    percent_state_change=0.00
    scheduled_downtime_depth=0
    }

service {
    host_name=dmds2
    service_description=Heartbeat link state
    modified_attributes=0
    check_command=check_heartbeat_link_ssh
    event_handler=
    has_been_checked=1
    should_be_scheduled=1
    check_execution_time=0.801
    check_latency=0.664
    check_type=0
    current_state=0
    last_hard_state=0
    current_attempt=1
    max_attempts=3
    state_type=1
    last_state_change=1246359004
    last_hard_state_change=1243938078
    last_time_ok=1246372504
    last_time_warning=0
    last_time_unknown=1216809716
    last_time_critical=1246358944
    plugin_output=Heartbeat Link OK: ib0group:ib0group:up eth0group:eth0group:up dmds1.localdomain:eth1:up dmds1.localdomain:eth0:up
    performance_data=
    last_check=1246372504
    next_check=1246372804
    current_notification_number=0
    last_notification=0
    next_notification=0
    no_more_notifications=0
    notifications_enabled=1
    active_checks_enabled=1
    passive_checks_enabled=1
    event_handler_enabled=1
    problem_has_been_acknowledged=0
    acknowledgement_type=0
    flap_detection_enabled=1
    failure_prediction_enabled=1
    process_performance_data=1
    obsess_over_service=1
    last_update=1246372714
    is_flapping=0
    percent_state_change=0.00
    scheduled_downtime_depth=0
    }

service {
    host_name=dmds2
    service_description=IB state
    modified_attributes=0
    check_command=check_iberr_ssh
    event_handler=
    has_been_checked=1
    should_be_scheduled=1
    check_execution_time=0.343
    check_latency=0.847
    check_type=0
    current_state=3
    last_hard_state=3
    current_attempt=3
    max_attempts=3
    state_type=1
    last_state_change=1245406102
    last_hard_state_change=1245406222
    last_time_ok=1245077931
    last_time_warning=0
    last_time_unknown=1246372607
    last_time_critical=1225726523
    plugin_output=Script could not be executed without errors: Possibly
    performance_data=
    last_check=1246372607
    next_check=1246372907
    current_notification_number=0
    last_notification=0
    next_notification=0
    no_more_notifications=0
    notifications_enabled=1
    active_checks_enabled=1
    passive_checks_enabled=1
    event_handler_enabled=1
    problem_has_been_acknowledged=0
    acknowledgement_type=0
    flap_detection_enabled=1
    failure_prediction_enabled=1
    process_performance_data=1
    obsess_over_service=1
    last_update=1246372714
    is_flapping=0
    percent_state_change=0.00
    scheduled_downtime_depth=0
    }

service {
    host_name=dmds2
    service_description=Lustre LBUG
    modified_attributes=0
    check_command=check_gangmet!lbug!1!1!LustreSrv!
    event_handler=
    has_been_checked=1
    should_be_scheduled=1
    check_execution_time=0.009
    check_latency=0.997
    check_type=0
    current_state=0
    last_hard_state=0
    current_attempt=1
    max_attempts=4
    state_type=1
    last_state_change=1225677178
    last_hard_state_change=1225677178
    last_time_ok=1246365510
    last_time_warning=0
    last_time_unknown=1225725126
    last_time_critical=1213443414
    plugin_output=lbug = 0, normal
    performance_data=
    last_check=1246365510
    next_check=1246372710
    current_notification_number=0
    last_notification=0
    next_notification=0
    no_more_notifications=0
    notifications_enabled=1
    active_checks_enabled=1
    passive_checks_enabled=1
    event_handler_enabled=1
    problem_has_been_acknowledged=0
    acknowledgement_type=0
    flap_detection_enabled=1
    failure_prediction_enabled=1
    process_performance_data=1
    obsess_over_service=1
    last_update=1246372714
    is_flapping=0
    percent_state_change=0.00
    scheduled_downtime_depth=0
    }

service {
    host_name=dmds2
    service_description=OSTs deactivated
    modified_attributes=0
    check_command=check_deactivated
    event_handler=
    has_been_checked=1
    should_be_scheduled=1
    check_execution_time=0.219
    check_latency=0.310
    check_type=0
    current_state=0
    last_hard_state=0
    current_attempt=1
    max_attempts=3
    state_type=1
    last_state_change=1246358775
    last_hard_state_change=1243947091
    last_time_ok=1246372275
    last_time_warning=1246358475
    last_time_unknown=1225810324
    last_time_critical=1243946191
    plugin_output=OK: 0/2 OSTs deactivated
    performance_data=
    last_check=1246372275
    next_check=1246373175
    current_notification_number=0
    last_notification=0
    next_notification=0
    no_more_notifications=0
    notifications_enabled=1
    active_checks_enabled=1
    passive_checks_enabled=1
    event_handler_enabled=1
    problem_has_been_acknowledged=0
    acknowledgement_type=0
    flap_detection_enabled=1
    failure_prediction_enabled=1
    process_performance_data=1
    obsess_over_service=1
    last_update=1246372714
    is_flapping=0
    percent_state_change=0.00
    scheduled_downtime_depth=0
    }

service {
    host_name=dmds2
    service_description=Udev path check
    modified_attributes=0
    check_command=check_udev_ssh!mds!
    event_handler=
    has_been_checked=1
    should_be_scheduled=1
    check_execution_time=5.061
    check_latency=0.758
    check_type=0
    current_state=0
    last_hard_state=0
    current_attempt=1
    max_attempts=3
    state_type=1
    last_state_change=1245912687
    last_hard_state_change=1216751762
    last_time_ok=1246372560
    last_time_warning=0
    last_time_unknown=1245912627
    last_time_critical=0
    plugin_output=7874: old priority 0, new priority -10
    performance_data=
    last_check=1246372560
    next_check=1246373040
    current_notification_number=0
    last_notification=0
    next_notification=0
    no_more_notifications=0
    notifications_enabled=1
    active_checks_enabled=1
    passive_checks_enabled=1
    event_handler_enabled=1
    problem_has_been_acknowledged=0
    acknowledgement_type=0
    flap_detection_enabled=1
    failure_prediction_enabled=1
    process_performance_data=1
    obsess_over_service=1
    last_update=1246372714
    is_flapping=0
    percent_state_change=0.00
    scheduled_downtime_depth=0
    }

service {
    host_name=dmds2
    service_description=software raids
    modified_attributes=0
    check_command=check_raids_ssh
    event_handler=
    has_been_checked=1
    should_be_scheduled=1
    check_execution_time=0.475
    check_latency=0.373
    check_type=0
    current_state=0
    last_hard_state=0
    current_attempt=1
    max_attempts=3
    state_type=1
    last_state_change=1216757705
    last_hard_state_change=1216751927
    last_time_ok=1246372305
    last_time_warning=0
    last_time_unknown=1216809589
    last_time_critical=0
    plugin_output=All (4) RAIDs ok.
    performance_data=
    last_check=1246372305
    next_check=1246373205
    current_notification_number=0
    last_notification=0
    next_notification=0
    no_more_notifications=0
    notifications_enabled=1
    active_checks_enabled=1
    passive_checks_enabled=1
    event_handler_enabled=1
    problem_has_been_acknowledged=0
    acknowledgement_type=0
    flap_detection_enabled=1
    failure_prediction_enabled=1
    process_performance_data=1
    obsess_over_service=1
    last_update=1246372714
    is_flapping=0
    percent_state_change=0.00
    scheduled_downtime_depth=0
    }

service {
    host_name=doss1
    service_description=HA state
    modified_attributes=0
    check_command=check_crm_ssh
    event_handler=
    has_been_checked=1
    should_be_scheduled=1
    check_execution_time=0.165
    check_latency=0.814
    check_type=0
    current_state=1
    last_hard_state=1
    current_attempt=3
    max_attempts=3
    state_type=1
    last_state_change=1246366590
    last_hard_state_change=1246366590
    last_time_ok=1218628561
    last_time_warning=1246372590
    last_time_unknown=1246356899
    last_time_critical=1246366290
    plugin_output=WARNING - DC choosen: 1/2 nodes online: 3/4 resources online: Resources NOT balanced!
    performance_data=
    last_check=1246372590
    next_check=1246372890
    current_notification_number=500
    last_notification=1246366594
    next_notification=1246402594
    no_more_notifications=0
    notifications_enabled=1
    active_checks_enabled=1
    passive_checks_enabled=1
    event_handler_enabled=1
    problem_has_been_acknowledged=0
    acknowledgement_type=0
    flap_detection_enabled=1
    failure_prediction_enabled=1
    process_performance_data=1
    obsess_over_service=1
    last_update=1246372714
    is_flapping=0
    percent_state_change=0.00
    scheduled_downtime_depth=0
    }

service {
    host_name=doss1
    service_description=Heartbeat link state
    modified_attributes=0
    check_command=check_heartbeat_link_ssh
    event_handler=
    has_been_checked=1
    should_be_scheduled=1
    check_execution_time=0.311
    check_latency=0.592
    check_type=0
    current_state=2
    last_hard_state=2
    current_attempt=3
    max_attempts=3
    state_type=1
    last_state_change=1246366335
    last_hard_state_change=1246366455
    last_time_ok=1246366035
    last_time_warning=0
    last_time_unknown=1246356856
    last_time_critical=1246372455
    plugin_output=Heartbeat Link CRITICAL: ib0group:ib0group:up eth0group:eth0group:up doss2.localdomain:eth1:dead doss2.localdomain:eth0:dead
    performance_data=
    last_check=1246372455
    next_check=1246372755
    current_notification_number=1
    last_notification=1246366464
    next_notification=1246402464
    no_more_notifications=0
    notifications_enabled=1
    active_checks_enabled=1
    passive_checks_enabled=1
    event_handler_enabled=1
    problem_has_been_acknowledged=0
    acknowledgement_type=0
    flap_detection_enabled=1
    failure_prediction_enabled=1
    process_performance_data=1
    obsess_over_service=1
    last_update=1246372714
    is_flapping=0
    percent_state_change=0.00
    scheduled_downtime_depth=0
    }

service {
    host_name=doss1
    service_description=IB state
    modified_attributes=0
    check_command=check_iberr_ssh
    event_handler=
    has_been_checked=1
    should_be_scheduled=1
    check_execution_time=0.168
    check_latency=0.753
    check_type=0
    current_state=3
    last_hard_state=3
    current_attempt=3
    max_attempts=3
    state_type=1
    last_state_change=1246358338
    last_hard_state_change=1246358458
    last_time_ok=1245078062
    last_time_warning=1207579729
    last_time_unknown=1246372558
    last_time_critical=1246356899
    plugin_output=Script could not be executed without errors: Possibly
    performance_data=
    last_check=1246372558
    next_check=1246372858
    current_notification_number=2
    last_notification=0
    next_notification=0
    no_more_notifications=0
    notifications_enabled=1
    active_checks_enabled=1
    passive_checks_enabled=1
    event_handler_enabled=1
    problem_has_been_acknowledged=0
    acknowledgement_type=0
    flap_detection_enabled=1
    failure_prediction_enabled=1
    process_performance_data=1
    obsess_over_service=1
    last_update=1246372714
    is_flapping=0
    percent_state_change=0.00
    scheduled_downtime_depth=0
    }

service {
    host_name=doss1
    service_description=Lustre LBUG
    modified_attributes=0
    check_command=check_gangmet!lbug!1!1!LustreSrv!
    event_handler=
    has_been_checked=1
    should_be_scheduled=1
    check_execution_time=0.007
    check_latency=0.967
    check_type=0
    current_state=0
    last_hard_state=0
    current_attempt=1
    max_attempts=4
    state_type=1
    last_state_change=1246357126
    last_hard_state_change=1246356946
    last_time_ok=1246372685
    last_time_warning=1246356946
    last_time_unknown=1246357066
    last_time_critical=1216383323
    plugin_output=lbug = 0, normal
    performance_data=
    last_check=1246372685
    next_check=1246372805
    current_notification_number=0
    last_notification=0
    next_notification=0
    no_more_notifications=0
    notifications_enabled=1
    active_checks_enabled=1
    passive_checks_enabled=1
    event_handler_enabled=1
    problem_has_been_acknowledged=0
    acknowledgement_type=0
    flap_detection_enabled=1
    failure_prediction_enabled=1
    process_performance_data=1
    obsess_over_service=1
    last_update=1246372714
    is_flapping=0
    percent_state_change=0.00
    scheduled_downtime_depth=0
    }

service {
    host_name=doss1
    service_description=OSTs filling
    modified_attributes=0
    check_command=check_full_osts_ssh
    event_handler=handle_osts_full
    has_been_checked=1
    should_be_scheduled=1
    check_execution_time=0.129
    check_latency=0.620
    check_type=0
    current_state=0
    last_hard_state=0
    current_attempt=1
    max_attempts=3
    state_type=1
    last_state_change=1246358668
    last_hard_state_change=1246356899
    last_time_ok=1246372468
    last_time_warning=0
    last_time_unknown=1246356899
    last_time_critical=1245413463
    plugin_output=DISK OK - free space: /mnt/lustre/ost100 4876771 MB (91% inode=99%): /mnt/lustre/ost101 5073097 MB (94% inode=99%):
    performance_data=/mnt/lustre/ost100=469382MB;5069030;5350643;0;5632256 /mnt/lustre/ost101=273057MB;5069030;5350643;0;5632256
    last_check=1246372468
    next_check=1246372768
    current_notification_number=0
    last_notification=0
    next_notification=0
    no_more_notifications=0
    notifications_enabled=1
    active_checks_enabled=1
    passive_checks_enabled=1
    event_handler_enabled=1
    problem_has_been_acknowledged=0
    acknowledgement_type=0
    flap_detection_enabled=1
    failure_prediction_enabled=1
    process_performance_data=1
    obsess_over_service=1
    last_update=1246372714
    is_flapping=0
    percent_state_change=0.00
    scheduled_downtime_depth=0
    }

service {
    host_name=doss1
    service_description=Udev path check
    modified_attributes=0
    check_command=check_udev_ssh!oss!
    event_handler=
    has_been_checked=1
    should_be_scheduled=1
    check_execution_time=2.158
    check_latency=0.303
    check_type=0
    current_state=0
    last_hard_state=0
    current_attempt=1
    max_attempts=3
    state_type=1
    last_state_change=1246039538
    last_hard_state_change=1246039538
    last_time_ok=1246372272
    last_time_warning=0
    last_time_unknown=1246039058
    last_time_critical=1245413153
    plugin_output=28600: old priority 0, new priority -10
    performance_data=
    last_check=1246372272
    next_check=1246372752
    current_notification_number=0
    last_notification=0
    next_notification=0
    no_more_notifications=0
    notifications_enabled=1
    active_checks_enabled=1
    passive_checks_enabled=1
    event_handler_enabled=1
    problem_has_been_acknowledged=0
    acknowledgement_type=0
    flap_detection_enabled=1
    failure_prediction_enabled=1
    process_performance_data=1
    obsess_over_service=1
    last_update=1246372714
    is_flapping=0
    percent_state_change=0.00
    scheduled_downtime_depth=0
    }

service {
    host_name=doss1
    service_description=software raids
    modified_attributes=0
    check_command=check_raids_ssh
    event_handler=
    has_been_checked=1
    should_be_scheduled=1
    check_execution_time=0.275
    check_latency=0.662
    check_type=0
    current_state=0
    last_hard_state=0
    current_attempt=1
    max_attempts=3
    state_type=1
    last_state_change=1246358997
    last_hard_state_change=1246356899
    last_time_ok=1246372504
    last_time_warning=0
    last_time_unknown=1246356899
    last_time_critical=1245413205
    plugin_output=All (4) RAIDs ok.
    performance_data=
    last_check=1246372504
    next_check=1246373404
    current_notification_number=0
    last_notification=0
    next_notification=0
    no_more_notifications=0
    notifications_enabled=1
    active_checks_enabled=1
    passive_checks_enabled=1
    event_handler_enabled=1
    problem_has_been_acknowledged=0
    acknowledgement_type=0
    flap_detection_enabled=1
    failure_prediction_enabled=1
    process_performance_data=1
    obsess_over_service=1
    last_update=1246372714
    is_flapping=0
    percent_state_change=8.42
    scheduled_downtime_depth=0
    }

service {
    host_name=doss2
    service_description=HA state
    modified_attributes=0
    check_command=check_crm_ssh
    event_handler=
    has_been_checked=1
    should_be_scheduled=1
    check_execution_time=0.139
    check_latency=0.929
    check_type=0
    current_state=3
    last_hard_state=3
    current_attempt=3
    max_attempts=3
    state_type=1
    last_state_change=1246366362
    last_hard_state_change=1246366362
    last_time_ok=1241079286
    last_time_warning=1246366062
    last_time_unknown=1246372662
    last_time_critical=1246357078
    plugin_output=Remote command execution failed: Use of uninitialized value in split at /usr/lib64/nagios/plugins/crm_check line 76.
    performance_data=
    last_check=1246372662
    next_check=1246372962
    current_notification_number=37
    last_notification=0
    next_notification=0
    no_more_notifications=0
    notifications_enabled=1
    active_checks_enabled=1
    passive_checks_enabled=1
    event_handler_enabled=1
    problem_has_been_acknowledged=0
    acknowledgement_type=0
    flap_detection_enabled=1
    failure_prediction_enabled=1
    process_performance_data=1
    obsess_over_service=1
    last_update=1246372714
    is_flapping=0
    percent_state_change=0.00
    scheduled_downtime_depth=0
    }

service {
    host_name=doss2
    service_description=Heartbeat link state
    modified_attributes=0
    check_command=check_heartbeat_link_ssh
    event_handler=
    has_been_checked=1
    should_be_scheduled=1
    check_execution_time=0.152
    check_latency=0.806
    check_type=0
    current_state=2
    last_hard_state=2
    current_attempt=3
    max_attempts=3
    state_type=1
    last_state_change=1246366465
    last_hard_state_change=1246366585
    last_time_ok=1246365865
    last_time_warning=0
    last_time_unknown=1246366165
    last_time_critical=1246372585
    plugin_output=Heartbeat Link CRITICAL: Heartbeat is stopped on this machine.
    performance_data=
    last_check=1246372585
    next_check=1246372885
    current_notification_number=1
    last_notification=1246366594
    next_notification=1246402594
    no_more_notifications=0
    notifications_enabled=1
    active_checks_enabled=1
    passive_checks_enabled=1
    event_handler_enabled=1
    problem_has_been_acknowledged=0
    acknowledgement_type=0
    flap_detection_enabled=1
    failure_prediction_enabled=1
    process_performance_data=1
    obsess_over_service=1
    last_update=1246372714
    is_flapping=0
    percent_state_change=0.00
    scheduled_downtime_depth=0
    }

service {
    host_name=doss2
    service_description=IB state
    modified_attributes=0
    check_command=check_iberr_ssh
    event_handler=
    has_been_checked=1
    should_be_scheduled=1
    check_execution_time=0.167
    check_latency=0.576
    check_type=0
    current_state=3
    last_hard_state=3
    current_attempt=3
    max_attempts=3
    state_type=1
    last_state_change=1245687516
    last_hard_state_change=1245687516
    last_time_ok=1244017389
    last_time_warning=0
    last_time_unknown=1246372450
    last_time_critical=1245687216
    plugin_output=Script could not be executed without errors: Possibly
    performance_data=
    last_check=1246372450
    next_check=1246372750
    current_notification_number=0
    last_notification=0
    next_notification=0
    no_more_notifications=0
    notifications_enabled=1
    active_checks_enabled=1
    passive_checks_enabled=1
    event_handler_enabled=1
    problem_has_been_acknowledged=0
    acknowledgement_type=0
    flap_detection_enabled=1
    failure_prediction_enabled=1
    process_performance_data=1
    obsess_over_service=1
    last_update=1246372714
    is_flapping=0
    percent_state_change=0.00
    scheduled_downtime_depth=0
    }

service {
    host_name=doss2
    service_description=Lustre LBUG
    modified_attributes=0
    check_command=check_gangmet!lbug!1!1!LustreSrv!
    event_handler=
    has_been_checked=1
    should_be_scheduled=1
    check_execution_time=0.008
    check_latency=0.878
    check_type=0
    current_state=0
    last_hard_state=0
    current_attempt=1
    max_attempts=4
    state_type=1
    last_state_change=1246366384
    last_hard_state_change=1246366384
    last_time_ok=1246372624
    last_time_warning=1246366264
    last_time_unknown=1246356931
    last_time_critical=1231327110
    plugin_output=lbug = 0, normal
    performance_data=
    last_check=1246372624
    next_check=1246372744
    current_notification_number=0
    last_notification=0
    next_notification=0
    no_more_notifications=0
    notifications_enabled=1
    active_checks_enabled=1
    passive_checks_enabled=1
    event_handler_enabled=1
    problem_has_been_acknowledged=0
    acknowledgement_type=0
    flap_detection_enabled=1
    failure_prediction_enabled=1
    process_performance_data=1
    obsess_over_service=1
    last_update=1246372714
    is_flapping=0
    percent_state_change=0.00
    scheduled_downtime_depth=0
    }

service {
    host_name=doss2
    service_description=OSTs filling
    modified_attributes=0
    check_command=check_full_osts_ssh
    event_handler=handle_osts_full
    has_been_checked=1
    should_be_scheduled=1
    check_execution_time=0.131
    check_latency=0.924
    check_type=0
    current_state=0
    last_hard_state=0
    current_attempt=1
    max_attempts=3
    state_type=1
    last_state_change=1246357081
    last_hard_state_change=1246357081
    last_time_ok=1246372660
    last_time_warning=1233204521
    last_time_unknown=1246356781
    last_time_critical=1244816573
    plugin_output=No OSTs mounted.
    performance_data=
    last_check=1246372660
    next_check=1246372960
    current_notification_number=0
    last_notification=0
    next_notification=0
    no_more_notifications=0
    notifications_enabled=1
    active_checks_enabled=1
    passive_checks_enabled=1
    event_handler_enabled=1
    problem_has_been_acknowledged=0
    acknowledgement_type=0
    flap_detection_enabled=1
    failure_prediction_enabled=1
    process_performance_data=1
    obsess_over_service=1
    last_update=1246372714
    is_flapping=0
    percent_state_change=0.00
    scheduled_downtime_depth=0
    }

service {
    host_name=doss2
    service_description=Udev path check
    modified_attributes=0
    check_command=check_udev_ssh!oss!
    event_handler=
    has_been_checked=1
    should_be_scheduled=1
    check_execution_time=0.341
    check_latency=0.613
    check_type=0
    current_state=0
    last_hard_state=0
    current_attempt=1
    max_attempts=3
    state_type=1
    last_state_change=1246366705
    last_hard_state_change=1246366705
    last_time_ok=1246372465
    last_time_warning=0
    last_time_unknown=1246366225
    last_time_critical=1240389140
    plugin_output=11142: old priority 0, new priority -10
    performance_data=
    last_check=1246372465
    next_check=1246372945
    current_notification_number=0
    last_notification=0
    next_notification=0
    no_more_notifications=0
    notifications_enabled=1
    active_checks_enabled=1
    passive_checks_enabled=1
    event_handler_enabled=1
    problem_has_been_acknowledged=0
    acknowledgement_type=0
    flap_detection_enabled=1
    failure_prediction_enabled=1
    process_performance_data=1
    obsess_over_service=1
    last_update=1246372714
    is_flapping=0
    percent_state_change=9.21
    scheduled_downtime_depth=0
    }

service {
    host_name=doss2
    service_description=software raids
    modified_attributes=0
    check_command=check_raids_ssh
    event_handler=
    has_been_checked=1
    should_be_scheduled=1
    check_execution_time=0.199
    check_latency=0.496
    check_type=0
    current_state=1
    last_hard_state=1
    current_attempt=3
    max_attempts=3
    state_type=1
    last_state_change=1246359190
    last_hard_state_change=1246359790
    last_time_ok=1239011847
    last_time_warning=1246372390
    last_time_unknown=1246356791
    last_time_critical=1244571200
    plugin_output=RAID md1 is degraded!
    performance_data=
    last_check=1246372390
    next_check=1246373290
    current_notification_number=75
    last_notification=1246359794
    next_notification=1246395794
    no_more_notifications=0
    notifications_enabled=1
    active_checks_enabled=1
    passive_checks_enabled=1
    event_handler_enabled=1
    problem_has_been_acknowledged=0
    acknowledgement_type=0
    flap_detection_enabled=1
    failure_prediction_enabled=1
    process_performance_data=1
    obsess_over_service=1
    last_update=1246372714
    is_flapping=0
    percent_state_change=8.68
    scheduled_downtime_depth=0
    }

service {
    host_name=osb1raid1
    service_description=Array disk health
    modified_attributes=0
    check_command=check_promise
    event_handler=
    has_been_checked=1
    should_be_scheduled=1
    check_execution_time=0.017
    check_latency=0.386
    check_type=0
    current_state=0
    last_hard_state=0
    current_attempt=1
    max_attempts=3
    state_type=1
    last_state_change=1228289632
    last_hard_state_change=1228289632
    last_time_ok=1246372313
    last_time_warning=1212080581
    last_time_unknown=1228310819
    last_time_critical=1212062776
    plugin_output=Array OK with  disks.
    performance_data=
    last_check=1246372313
    next_check=1246372793
    current_notification_number=0
    last_notification=0
    next_notification=0
    no_more_notifications=0
    notifications_enabled=1
    active_checks_enabled=1
    passive_checks_enabled=1
    event_handler_enabled=1
    problem_has_been_acknowledged=0
    acknowledgement_type=0
    flap_detection_enabled=1
    failure_prediction_enabled=1
    process_performance_data=1
    obsess_over_service=1
    last_update=1246372714
    is_flapping=0
    percent_state_change=0.00
    scheduled_downtime_depth=0
    }

service {
    host_name=osb1raid1
    service_description=http
    modified_attributes=0
    check_command=check_http
    event_handler=
    has_been_checked=1
    should_be_scheduled=1
    check_execution_time=1.476
    check_latency=0.975
    check_type=0
    current_state=0
    last_hard_state=0
    current_attempt=1
    max_attempts=3
    state_type=1
    last_state_change=1244076529
    last_hard_state_change=1233223602
    last_time_ok=1246372058
    last_time_warning=0
    last_time_unknown=0
    last_time_critical=1244076229
    plugin_output=HTTP OK HTTP/1.1 200 HTTP - 7385 bytes in 1.468 seconds
    performance_data=time=1.467966s;;;0.000000 size=7385B;;;0
    last_check=1246372058
    next_check=1246372958
    current_notification_number=0
    last_notification=0
    next_notification=0
    no_more_notifications=0
    notifications_enabled=1
    active_checks_enabled=1
    passive_checks_enabled=1
    event_handler_enabled=1
    problem_has_been_acknowledged=0
    acknowledgement_type=0
    flap_detection_enabled=1
    failure_prediction_enabled=1
    process_performance_data=1
    obsess_over_service=1
    last_update=1246372714
    is_flapping=0
    percent_state_change=0.00
    scheduled_downtime_depth=0
    }
"""


class NagiosStatusLogImporterTest(unittest.TestCase):
    def runTest( self ):
        importer = NagiosStatusLogImporter()
        requests = [request for request in importer._parseNagiosStatusLog( NAGIOS_STATUS_LOG )]
        assert len( requests ) == 64
        for request in requests:
            assert isinstance( request, Metric )

suite = unittest.TestSuite()
suite.addTest( NagiosStatusLogImporterTest() )
